template<class T>
void DynamicArray<T>::valid() const{
    ASSERT(this != 0, "internal error");
    ASSERT(this->size() >= 0, "internal error");
    ASSERT(this->size() == 0 || this->arr != 0, "internal error");
    ASSERT(this->size() >  0 || this->arr == 0, "internal error");
}

template<class T>
void DynamicArray<T>::init(const int sz){
    this->arr = 0;
    this->sz = 0;
    ASSERT(sz >= 0, "size is incorrect");

    if (sz > 0){
        this->arr = new T[sz];
        ASSERT(this->arr != 0, "no memory");
        this->sz = sz;
    }

    valid();
}

template<class T>
DynamicArray<T>::DynamicArray(const int sz, const T src[])
:   Array<T>(), arr(0){
    this->init(sz);
    if (src == 0){
        this->zeroize();
    }else{
        this->move(0, src, sz);
    }
}

template<class T>
DynamicArray<T>::DynamicArray(const Array<T>& src)
:   Array<T>(), arr(0){
    const int sz = src.size();
    this->init(sz);
    this->move(0, src, 0, sz);
}

template<class T>
DynamicArray<T>::~DynamicArray(){
    valid();

    if (this->size() > 0){
        this->zeroize();
        delete[] this->arr;
    }
    this->sz = -1;
    this->arr = 0;
}

template<class T>
void DynamicArray<T>::operator=(const Array<T>& src){
    this->assign(src);
}

